home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume4 / psinter-patch2 < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  56.7 KB

  1. Path: xanth!mcnc!gatech!bloom-beacon!husc6!m2c!necntc!ncoast!allbery
  2. From: jgm@k.gp.cs.cmu.edu (John Myers)
  3. Newsgroups: comp.sources.misc
  4. Subject: v04i007: Postscript interpreter patches (2 of 2)
  5. Message-ID: <12089@ncoast.UUCP>
  6. Date: 28 Jul 88 23:43:36 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: jgm@k.gp.cs.cmu.edu (John Myers)
  9. Organization: System/Technology Development Corp.
  10. Lines: 1982
  11. Approved: allbery@ncoast.UUCP
  12.  
  13. Posting-number: Volume 4, Issue 7
  14. Submitted-by: "John Myers" <jgm@k.gp.cs.cmu.edu>
  15. Archive-name: psinter-patch2
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of shell archive."
  24. # Contents:  ps.diff.v3
  25. # Wrapped by jm36@cycle4.andrew.cmu.edu on Thu Jul 28 19:29:36 1988
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f ps.diff.v3 -a "${1}" != "-c" ; then 
  28.   echo shar: Will not over-write existing file \"ps.diff.v3\"
  29. else
  30. echo shar: Extracting \"ps.diff.v3\" \(54477 characters\)
  31. sed "s/^X//" >ps.diff.v3 <<'END_OF_ps.diff.v3'
  32. XMake sure you have already applied patch 'ps.diff.v2'.
  33. X
  34. XIf you already have the file "source/X11.c", move it to a safe place
  35. Xbefore applying this patch.
  36. X
  37. XTo apply this, you need the 'patch' program which is available from
  38. Xthe comp.sources.unix archives.
  39. X
  40. XChange directories to the top-level postscript directory (the one with
  41. Xthe file "MANIFEST" in it) and apply this patch with the command:
  42. X
  43. Xpatch -p0 <ps.diff.v3
  44. X
  45. X                _.John G. Myers
  46. X                jm36+@andrew.cmu.edu
  47. X
  48. X*** /tmp/CHANGES.JGM.v2    Thu Jul 28 14:59:27 1988
  49. X--- ./CHANGES.JGM    Thu Jul 28 15:07:01 1988
  50. X***************
  51. X*** 60,65 ****
  52. X--- 60,80 ----
  53. X  
  54. X  Added operators letter, note, and legal.
  55. X  
  56. X+                   Version 3:
  57. X+ 
  58. X+ Bugs fixed:
  59. X+ 
  60. X+ The fourth parameter to the "framedevice" is no longer ignored.  psrc
  61. X+ has been modified so that if a driver defines the postscript operator
  62. X+ "outputpage", it will be called instead of the "beep and wait for
  63. X+ input" routine when the copypage or showpage command is executed.
  64. X+ 
  65. X+ Enhancements made:
  66. X+ 
  67. X+ Barry Shein's speedups have been incorporated.
  68. X+ 
  69. X+ A version of the X11 driver is included.
  70. X+ 
  71. X                  John G. Myers
  72. X                  jm36@andrew.cmu.edu
  73. X                  jgm@k.gp.cs.cmu.edu
  74. Xdiff -cr /usr/tmp/ps/postscript/psrc ./postscript/psrc
  75. X*** /usr/tmp/ps/postscript/psrc    Thu Jul 28 14:00:59 1988
  76. X--- ./postscript/psrc    Thu Jul 28 14:17:45 1988
  77. X***************
  78. X*** 69,84 ****
  79. X  %/tty (|cat -u </dev/tty) (r) file def
  80. X  
  81. X  /showpage {
  82. X!     copypage initgraphics
  83. X!     beep print flush
  84. X!     false echo
  85. X!     { tty read { pop } if } stopped
  86. X!     true echo
  87. X!     not {
  88. X!         erasepage
  89. X!     } if
  90. X  } def
  91. X  
  92. X  /run { { (r) file } stopped { pop stop } if cvx exec } def
  93. X  /prompt { (PS>) print } def
  94. X  
  95. X--- 69,87 ----
  96. X  %/tty (|cat -u </dev/tty) (r) file def
  97. X  
  98. X  /showpage {
  99. X!     copypage initgraphics erasepage
  100. X  } def
  101. X  
  102. X+ systemdict /outputpage known not {
  103. X+     /outputpage {
  104. X+     beep print flush
  105. X+       false echo
  106. X+       { tty read { pop } if } stopped
  107. X+       true echo
  108. X+     pop
  109. X+     } def
  110. X+ } if
  111. X+ 
  112. X  /run { { (r) file } stopped { pop stop } if cvx exec } def
  113. X  /prompt { (PS>) print } def
  114. X  
  115. X***************
  116. X*** 423,429 ****
  117. X      /h 11 72 mul f mul cvi def
  118. X      /w 8.25 72 mul f mul 8 div cvi def
  119. X      m 5 h put
  120. X!     m w h [] framedevice
  121. X      end
  122. X  } def
  123. X  
  124. X--- 426,432 ----
  125. X      /h 11 72 mul f mul cvi def
  126. X      /w 8.25 72 mul f mul 8 div cvi def
  127. X      m 5 h put
  128. X!     m w h /outputpage load framedevice    % jgm
  129. X      end
  130. X  } def
  131. X  
  132. X***************
  133. X*** 435,441 ****
  134. X      /h 11 72 mul f mul cvi def
  135. X      /w 8.25 72 mul f mul 8 div cvi def
  136. X      m 5 h put
  137. X!     m w h [] framedevice
  138. X      end
  139. X  } def
  140. X  
  141. X--- 438,444 ----
  142. X      /h 11 72 mul f mul cvi def
  143. X      /w 8.25 72 mul f mul 8 div cvi def
  144. X      m 5 h put
  145. X!     m w h /outputpage load framedevice    % jgm
  146. X      end
  147. X  } def
  148. X  
  149. X***************
  150. X*** 446,452 ****
  151. X      /h 11 72 mul f mul cvi def
  152. X      /w 8.25 72 mul f mul 8 div cvi def
  153. X      m 5 h put
  154. X!     m w h [] framedevice
  155. X      end
  156. X  } def
  157. X  
  158. X--- 449,455 ----
  159. X      /h 11 72 mul f mul cvi def
  160. X      /w 8.25 72 mul f mul 8 div cvi def
  161. X      m 5 h put
  162. X!     m w h /outputpage load framedevice    % jgm
  163. X      end
  164. X  } def
  165. X  
  166. X***************
  167. X*** 457,463 ****
  168. X      /h 8.25 72 mul f mul cvi def
  169. X      /w 11.75 2 div 72 mul f mul 8 div cvi def
  170. X      m 5 h put
  171. X!     m w h [] framedevice
  172. X      end
  173. X  } def
  174. X  
  175. X--- 460,466 ----
  176. X      /h 8.25 72 mul f mul cvi def
  177. X      /w 11.75 2 div 72 mul f mul 8 div cvi def
  178. X      m 5 h put
  179. X!     m w h /outputpage load framedevice    % jgm
  180. X      end
  181. X  } def
  182. X  
  183. X***************
  184. X*** 467,473 ****
  185. X      /f m 0 get def
  186. X      /h 8.25 72 mul f mul cvi def
  187. X      /w 11.75 72 mul f mul 8 div cvi def
  188. X!     [ 0 f f 0 0 0] w h [] framedevice
  189. X      end
  190. X  } def
  191. X  
  192. X--- 470,476 ----
  193. X      /f m 0 get def
  194. X      /h 8.25 72 mul f mul cvi def
  195. X      /w 11.75 72 mul f mul 8 div cvi def
  196. X!     [ 0 f f 0 0 0] w h /outputpage load framedevice % jgm
  197. X      end
  198. X  } def
  199. X  
  200. X***************
  201. X*** 480,486 ****
  202. X      /h 11 72 mul f mul cvi def
  203. X      /w 8.5 72 mul f mul 8 div cvi def
  204. X      m 5 h put
  205. X!     m w h [] framedevice
  206. X      end
  207. X  } def
  208. X  
  209. X--- 483,489 ----
  210. X      /h 11 72 mul f mul cvi def
  211. X      /w 8.5 72 mul f mul 8 div cvi def
  212. X      m 5 h put
  213. X!     m w h /outputpage load framedevice
  214. X      end
  215. X  } def
  216. X  
  217. X***************
  218. X*** 493,499 ****
  219. X      /h 14 72 mul f mul cvi def
  220. X      /w 8.5 72 mul f mul 8 div cvi def
  221. X      m 5 h put
  222. X!     m w h [] framedevice
  223. X      end
  224. X  } def
  225. X  
  226. X--- 496,502 ----
  227. X      /h 14 72 mul f mul cvi def
  228. X      /w 8.5 72 mul f mul 8 div cvi def
  229. X      m 5 h put
  230. X!     m w h /outputpage load framedevice
  231. X      end
  232. X  } def
  233. X  
  234. X*** /usr/tmp/ps/source/makefile    Thu Jul 28 13:53:39 1988
  235. X--- ./source/makefile    Thu Jul 28 15:36:09 1988
  236. X***************
  237. X*** 2,10 ****
  238. X--- 2,20 ----
  239. X      integer.o main.o math.o misc.o name.o operator.o\
  240. X      poly.o property.o real.o save.o stack.o string.o unix.o
  241. X  LIBS=libww.a -lsuntool -lsunwindow -lpixrect -g
  242. X+ XLIB=/usr/lib/libX11.a
  243. X  GRAPHICS=cache.o colour.o device.o fill.o font.o gsave.o image.o mat.o matrix.o\
  244. X      pat.o path.o state.o stroke.o
  245. X  
  246. X+ SOURCES=array.c boolean.c config.c control.c dictionary.c file.c\
  247. X+     integer.c main.c math.c misc.c name.c operator.c\
  248. X+     poly.c property.c real.c save.c stack.c string.c unix.c\
  249. X+     cache.c colour.c device.c fill.c font.c gsave.c image.c mat.c matrix.c\
  250. X+     pat.c path.c state.c stroke.c
  251. X+ LINT=lint
  252. X+ LFLAGS= -lm
  253. X+ 
  254. X+ 
  255. X  # For SUN with 68881
  256. X  #CFLAGS=-O -f68881
  257. X  
  258. X***************
  259. X*** 11,39 ****
  260. X  # For others
  261. X  CFLAGS=-O
  262. X  
  263. X! #default: sunPS
  264. X  
  265. X  PS:    $(OBJECTS) $(GRAPHICS) hard.o canon.a
  266. X!     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) hard.o canon.a -lm `libs` -o PS
  267. X  
  268. X  sunPS:    $(OBJECTS) $(GRAPHICS) pixrect.o canon.a
  269. X!     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) pixrect.o canon.a -lm -lpixrect -o sunPS
  270. X  
  271. X  CPS:    $(OBJECTS) $(GRAPHICS) colour-ww.o trapezoid.o canon.o
  272. X!     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) colour-ww.o canon.o trapezoid.o -lm `libs` -o CPS
  273. X  
  274. X  postscript:    $(OBJECTS) $(GRAPHICS) adapter.o protocol.o
  275. X!     cc $(CFLAGS) $(OBJECTS) $(GRAPHICS) adapter.o protocol.o -lm -o postscript
  276. X  
  277. X  XPS:    $(OBJECTS) $(GRAPHICS) X.o
  278. X!     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) X.o -lm -lX -o XPS
  279. X  
  280. X  canon.a:    canon.o screen.o trapezoid.o paint.o
  281. X      ar ruv canon.a canon.o screen.o trapezoid.o paint.o
  282. X      ranlib canon.a
  283. X  
  284. X  viewer:    protocol.o viewer.o hard.o canon.a
  285. X!     cc protocol.o viewer.o hard.o canon.a `libs` -o viewer
  286. X  
  287. X  all:    PS postscript viewer
  288. X  
  289. X--- 21,56 ----
  290. X  # For others
  291. X  CFLAGS=-O
  292. X  
  293. X! default: sunPS
  294. X  
  295. X+ xps: $(OBJECTS) $(GRAPHICS) X11.o canon.a $(XLIB)
  296. X+     rm -f xps
  297. X+     $(CC) -o xps $(CFLAGS) $(OBJECTS) $(GRAPHICS) X11.o canon.a -lm $(XLIB)
  298. X+ 
  299. X  PS:    $(OBJECTS) $(GRAPHICS) hard.o canon.a
  300. X!     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) hard.o canon.a -lm `libs` -o PS
  301. X  
  302. X  sunPS:    $(OBJECTS) $(GRAPHICS) pixrect.o canon.a
  303. X!     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) pixrect.o canon.a -lm -lpixrect -o sunPS
  304. X  
  305. X  CPS:    $(OBJECTS) $(GRAPHICS) colour-ww.o trapezoid.o canon.o
  306. X!     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) colour-ww.o canon.o trapezoid.o -lm `libs` -o CPS
  307. X  
  308. X  postscript:    $(OBJECTS) $(GRAPHICS) adapter.o protocol.o
  309. X!     $(CC) $(CFLAGS) $(OBJECTS) $(GRAPHICS) adapter.o protocol.o -lm -o postscript
  310. X  
  311. X  XPS:    $(OBJECTS) $(GRAPHICS) X.o
  312. X!     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) X.o -lm -lX -o XPS
  313. X  
  314. X+ lint:
  315. X+     $(LINT) $(LFLAGS) $(SOURCES) $(LINTFILTER)
  316. X+ 
  317. X  canon.a:    canon.o screen.o trapezoid.o paint.o
  318. X      ar ruv canon.a canon.o screen.o trapezoid.o paint.o
  319. X      ranlib canon.a
  320. X  
  321. X  viewer:    protocol.o viewer.o hard.o canon.a
  322. X!     $(CC) protocol.o viewer.o hard.o canon.a `libs` -o viewer
  323. X  
  324. X  all:    PS postscript viewer
  325. X  
  326. X***************
  327. X*** 44,50 ****
  328. X  orion:    orion.o installorion orionlib
  329. X  
  330. X  X.o:    
  331. X!     cc -c X.c
  332. X  
  333. X  wwlib:
  334. X      if [ -f libww.a ]; \
  335. X--- 61,67 ----
  336. X  orion:    orion.o installorion orionlib
  337. X  
  338. X  X.o:    
  339. X!     $(CC) -c X.c
  340. X  
  341. X  wwlib:
  342. X      if [ -f libww.a ]; \
  343. X*** /dev/null    Thu Jul 28 10:26:48 1988
  344. X--- ./source/X11.c    Wed Jul 27 18:15:31 1988
  345. X***************
  346. X*** 0 ****
  347. X--- 1,667 ----
  348. X+ /*
  349. X+  * Copyright (C) Rutherford Appleton Laboratory 1987
  350. X+  * 
  351. X+  * This source may be copied, distributed, altered or used, but not sold for profit
  352. X+  * or incorporated into a product except under licence from the author.
  353. X+  * It is not in the public domain.
  354. X+  * This notice should remain in the source unaltered, and any changes to the source
  355. X+  * made by persons other than the author should be marked as such.
  356. X+  * 
  357. X+  *    Crispin Goswell @ Rutherford Appleton Laboratory caag@uk.ac.rl.vd
  358. X+  */
  359. X+ #include "main.h"
  360. X+ #include "graphics.h"
  361. X+ #include <X11/Xlib.h>
  362. X+ #include <X11/Xutil.h>
  363. X+ #include <X11/Xatom.h>
  364. X+ #include <stdio.h>
  365. X+ #include "canon.h"
  366. X+ 
  367. X+ char *DriverType = "X11"; /* jgm */
  368. X+ 
  369. X+ static void Punt(str)
  370. X+ char *str;
  371. X+ {
  372. X+     fprintf(stderr, "%s\n", str);
  373. X+     exit(1);
  374. X+ }
  375. X+ 
  376. X+ 
  377. X+ 
  378. X+ static Display *dpy;
  379. X+ 
  380. X+ typedef struct _HardwareRec {
  381. X+     Drawable w;
  382. X+ } HardwareRec, *Hardware;
  383. X+ 
  384. X+ #ifdef CANON
  385. X+ struct hardware
  386. X+ {
  387. X+     /*
  388. X+      * Each driver is expected to provide its own definition of this
  389. X+      * structure.  It is only ever used as a pointer and is never dereferenced
  390. X+      * outside the driver.
  391. X+      */
  392. X+     int pad;
  393. X+ };
  394. X+ #endif CANON
  395. X+ 
  396. X+ /*
  397. X+  * This file describes the interface that PostScript requires to the graphics
  398. X+  * system at Version 1.4.
  399. X+  *     
  400. X+  * ''Hardware'' in this context refers to a pointer to windows and/or bitmaps
  401. X+  * and is the lowest level of access that PostScript is interested in. Any
  402. X+  * Hardware parameter may be expected to be NULL.
  403. X+  */
  404. X+ 
  405. X+ /********************* CREATION OF WINDOWS AND BITMAPS *******************/
  406. X+ 
  407. X+ #define SCREEN 0        /* What to use as our screen number. */
  408. X+ #define MIN(x, y)    (((x) < (y)) ? (x) : (y))
  409. X+ 
  410. X+ static GC fillgc[16];
  411. X+ 
  412. X+ struct hardware *InitHardware ()
  413. X+ {
  414. X+     XGCValues values;
  415. X+     int i;
  416. X+     if ((dpy = XOpenDisplay(dpy)) == NULL)
  417. X+     Punt("Could not open display");
  418. X+     InitTransfer(DisplayHeight(dpy, SCREEN) / 11);
  419. X+     /* This defines our screen as being 11 inches high, no matter what its */
  420. X+     /* real size.  What a hack. */
  421. X+     values.foreground = AllPlanes;
  422. X+     for (i=0 ; i<16 ; i++) {
  423. X+     values.function = i;
  424. X+     fillgc[i] = XCreateGC(dpy, RootWindow(dpy, SCREEN),
  425. X+                   GCFunction | GCForeground, &values);
  426. X+     }
  427. X+ }
  428. X+ /*
  429. X+  * InitHardware () returns a default device which PostScript may use
  430. X+  * immediately (or NULL if not appropriate).  Its size and shape are not
  431. X+  * defined. Most typically the user will want to start up another device
  432. X+  * before it is used anyway. No attempt will be made by PostScript to Destroy
  433. X+  * the resulting device.
  434. X+  */
  435. X+ 
  436. X+ static struct hardware *NewHardware(width, height)
  437. X+ int width, height;
  438. X+ {
  439. X+     struct hardware *to;
  440. X+     Hardware hard;
  441. X+     to = (struct hardware *) malloc(sizeof(struct hardware));
  442. X+     hard = (Hardware) malloc(sizeof(HardwareRec));
  443. X+     to->hard.addr = (char *) hard;
  444. X+     to->flags = 0;
  445. X+     to->aux = to->clip = NULL;
  446. X+     to->extent = NewDevicePoint(width, height);
  447. X+     hard->w = NULL;
  448. X+     return to;
  449. X+ }
  450. X+ 
  451. X+ 
  452. X+ struct hardware *NewBitmapHardware (width, height)
  453. X+ int width, height;
  454. X+ {
  455. X+     struct hardware *to = NewHardware(width, height);
  456. X+     Hardware hard = (Hardware) to->hard.addr;
  457. X+     to->flags = NULL;
  458. X+     hard->w = XCreatePixmap(dpy, RootWindow(dpy, SCREEN), width, height,
  459. X+                 DefaultDepth(dpy, SCREEN));
  460. X+     XFillRectangle(dpy, hard->w, fillgc[GXclear], 0, 0, width, height);
  461. X+ 
  462. X+ /*    {
  463. X+     static int y = 0;
  464. X+     XSetWindowAttributes attributes;
  465. X+     hard->w = XCreateSimpleWindow(dpy, RootWindow(dpy, SCREEN), 700, y,
  466. X+                   width, height, 1, BlackPixel(dpy, SCREEN),
  467. X+                   WhitePixel(dpy, SCREEN));
  468. X+     attributes.override_redirect = TRUE;
  469. X+     XChangeWindowAttributes(dpy, hard->w, CWOverrideRedirect, &attributes);
  470. X+     XMapWindow(dpy, hard->w);
  471. X+     y+=30;
  472. X+     }*/
  473. X+     return to;
  474. X+ }
  475. X+ 
  476. X+ struct hardware *NewWindowHardware (width, height)
  477. X+ int width, height;
  478. X+ {
  479. X+     struct hardware *to = NewHardware(width, height);
  480. X+     Hardware hard = (Hardware) to->hard.addr;
  481. X+     XEvent event;
  482. X+     unsigned long vmask;
  483. X+     XSetWindowAttributes xswa;
  484. X+ 
  485. X+     to->flags = ISWIN;
  486. X+ /*
  487. X+     hard->w = XCreateSimpleWindow(dpy, RootWindow(dpy, SCREEN), 0, 0,
  488. X+                   width, height, 1, BlackPixel(dpy, SCREEN),
  489. X+                   0);
  490. X+ */
  491. X+     vmask = CWBackPixel|CWBorderPixel|CWBackingStore|
  492. X+       CWBackingPlanes|CWSaveUnder;
  493. X+     xswa.background_pixel = WhitePixel(dpy,SCREEN);
  494. X+     xswa.border_pixel = BlackPixel(dpy,SCREEN);
  495. X+     xswa.backing_store = Always;
  496. X+     xswa.backing_planes = AllPlanes;
  497. X+     xswa.save_under = True;
  498. X+ 
  499. X+     hard->w = XCreateWindow(dpy,RootWindow(dpy,SCREEN),
  500. X+                 0,0,
  501. X+                 width,height,
  502. X+                 1,DefaultDepth(dpy,SCREEN),
  503. X+                 InputOutput,DefaultVisual(dpy,SCREEN),
  504. X+                 vmask,&xswa);
  505. X+ 
  506. X+     XChangeProperty(dpy,hard->w,XA_WM_NAME,XA_STRING,8,
  507. X+             PropModeReplace,"POSTSCRIPT",10);
  508. X+ 
  509. X+     XSelectInput(dpy, hard->w, ExposureMask);
  510. X+     XMapWindow(dpy, hard->w);
  511. X+     XNextEvent(dpy, &event);
  512. X+     XSelectInput(dpy, hard->w, 0);
  513. X+     return to;
  514. X+ }
  515. X+ /*
  516. X+  * NewBitmapHardware () is expected to create a new bitmap. Only one plane
  517. X+  * will be needed.
  518. X+  *     
  519. X+  * NewWindowHardware () is expected to create a window on the screen. On a
  520. X+  * colour system this will be expected to support full colour.
  521. X+  */
  522. X+ 
  523. X+ #ifdef CANON
  524. X+ int IsWindowHardware (h)
  525. X+ struct hardware *h;
  526. X+ {}
  527. X+ #endif CANON
  528. X+ /*
  529. X+  * IsWindowHardware () should return TRUE if the hardware is a window, FALSE
  530. X+  * otherwise.  NULL is a window.
  531. X+  */
  532. X+ 
  533. X+ void DestroyHardware (h)
  534. X+ struct hardware *h;
  535. X+ {
  536. X+     if (h) {
  537. X+     Hardware hard = (Hardware) h->hard.addr;
  538. X+     if (IsWindowHardware(h))
  539. X+         XDestroyWindow(dpy, hard->w);
  540. X+     else
  541. X+         XFreePixmap(dpy, hard->w);
  542. X+     }
  543. X+ }
  544. X+ /*
  545. X+  *     
  546. X+  * DestroyHardware () should release the resources required by the hardware,
  547. X+  * bitmap or window.  This should cause a window device to vanish. NULL is not
  548. X+  * an error (does nothing).
  549. X+  */
  550. X+ 
  551. X+ 
  552. X+ #ifdef CANON
  553. X+ Matrix DeviceMatrix (width, height)
  554. X+ int width, height;
  555. X+ {}
  556. X+ #endif CANON
  557. X+ 
  558. X+ /*
  559. X+  *
  560. X+  * DeviceMatrix () should return a matrix appropriate to a device of the given
  561. X+  * height and width.  For a typical display with a graphics origin at the top
  562. X+  * left of a window, an appropriate definition would be:
  563. X+  *     
  564. X+  * Matrix DeviceMatrix (width, height)
  565. X+  * int width, height;
  566. X+  * {
  567. X+  *     return NewMatrix (PIXELS_PER_INCH / 72.0, 0.0, 0.0,
  568. X+  *                  -PIXELS_PER_INCH / 72.0, 0.0, (float) height);
  569. X+  * }
  570. X+  */
  571. X+ 
  572. X+ #ifdef CANON
  573. X+ DevicePoint HardwareExtent (h)
  574. X+ struct hardware *h;
  575. X+ {}
  576. X+ #endif
  577. X+ /*
  578. X+  * HardwareExtent () returns a DevicePoint describing the width and height of
  579. X+  * the argument.  NULL has extent NewDevicePoint (0, 0).
  580. X+  */
  581. X+ 
  582. X+ /*************************** OUTPUT PRIMITIVES ******************************/    
  583. X+ 
  584. X+ void BitBlt (from, to, fromPoint, toPoint, extent, rop)
  585. X+ struct hardware *from, *to;
  586. X+ DevicePoint toPoint, fromPoint, extent;
  587. X+ int rop;
  588. X+ {
  589. X+     Hardware fromhard, tohard;
  590. X+     static int count = 0;
  591. X+     if (to == NULL) return;
  592. X+     tohard = (Hardware) to->hard.addr;
  593. X+     if (from == NULL) {
  594. X+     XFillRectangle(dpy, tohard->w, fillgc[rop], toPoint.dx, toPoint.dy,
  595. X+                extent.dx, extent.dy);
  596. X+     } else {
  597. X+     fromhard = (Hardware) from->hard.addr;
  598. X+     XCopyArea(dpy, fromhard->w, tohard->w, fillgc[rop], fromPoint.dx,
  599. X+           fromPoint.dy, extent.dx, extent.dy, toPoint.dx, toPoint.dy);
  600. X+     }
  601. X+     if (count++ % 50 == 0) XSync(dpy, 0);
  602. X+ }
  603. X+ 
  604. X+ #ifdef CANON
  605. X+ void Paint (from, to, fromPoint, toPoint, extent, colour)
  606. X+ struct hardware *from, *to;
  607. X+ DevicePoint toPoint, fromPoint, extent;
  608. X+ Colour colour;
  609. X+ {}
  610. X+ #endif
  611. X+ 
  612. X+ /*
  613. X+  *     
  614. X+  * BitBlt () is a full function RasterOp. The 'rop' argument will have values
  615. X+  * as described in the header file hard.h. If the from argument is NULL it is
  616. X+  * taken to be a bitmap full of ones the shape of the fromPoint and extent. If
  617. X+  * the to argument is NULL, this is a no-op.
  618. X+  *
  619. X+  * Paint () is an addition to BitBlt. Bits that are set in the source are
  620. X+  * Painted into the destination in the given colour with a copying rasterop so
  621. X+  * that they replace pixels previously there. If the machine does not support
  622. X+  * colour windows, half-toning should be performed.  Colour values have hue,
  623. X+  * saturation and brightness components. on a black and white or greyscale
  624. X+  * system the brightness value will be a FP value between 0.0 (black) and 1.1
  625. X+  * (white), which can be used as a grey level.
  626. X+  *     
  627. X+  * Paint is expected to mask with the clip mask. BitBlt is not,
  628. X+  */
  629. X+ 
  630. X+ #ifdef CANON
  631. X+ void BitBltTrapezoid(to, lefttop, leftbottom, righttop, rightbottom,
  632. X+              top, bottom, rop)
  633. X+ struct hardware *to;
  634. X+ DevicePoint lefttop, leftbottom, righttop, rightbottom;
  635. X+ int top, bottom, rop;
  636. X+ {}
  637. X+ #endif CANON
  638. X+ 
  639. X+ #ifdef CANON
  640. X+ void PaintTrapezoid (to, lefttop, leftbottom, righttop, rightbottom,
  641. X+              top, bottom, colour)
  642. X+ struct hardware *to;
  643. X+ DevicePoint lefttop, leftbottom, righttop, rightbottom;
  644. X+ int top, bottom;
  645. X+ Colour colour;
  646. X+ {}
  647. X+ #endif CANON
  648. X+ 
  649. X+ /*
  650. X+  * BitBltTrapezoid () and PaintTrapezoid () render a complete trapezoidal
  651. X+  * shape.  The corners of the trapezoid may lie far outside the range of
  652. X+  * interesting scan-lines, but the slope of the line should be clipped by the
  653. X+  * top and bottom. The coordinates are half-open.
  654. X+  */
  655. X+ 
  656. X+ void BitBltLine (h, fromPoint, toPoint, rop)
  657. X+ struct hardware *h;
  658. X+ DevicePoint fromPoint, toPoint;
  659. X+ int rop;
  660. X+ {
  661. X+     if (h) {
  662. X+     Hardware hard = (Hardware) h->hard.addr;
  663. X+     XDrawLine(dpy, hard->w, fillgc[rop], fromPoint.dx, fromPoint.dy,
  664. X+           toPoint.dx, toPoint.dy);
  665. X+     }
  666. X+ }
  667. X+ 
  668. X+ #ifdef CANON
  669. X+ void PaintLine (h, fromPoint, toPoint, colour)
  670. X+ struct hardware *h;
  671. X+ DevicePoint fromPoint, toPoint;
  672. X+ Colour colour;
  673. X+ {}
  674. X+ #endif CANON
  675. X+ 
  676. X+ /*
  677. X+  *     
  678. X+  *     BitBltLine () is expected to draw a line between the given points
  679. X+  *     with the given RasterOp and colour masking.
  680. X+  *     The line should be one pixel wide and half-open.
  681. X+  *     [Thicker lines are done with BitBlt.]
  682. X+  *     
  683. X+  *     PaintLine () is expected to Paint a line by analogy with Paint
  684. X+  *     and BitBlt.
  685. X+  */
  686. X+ 
  687. X+ void BitBltBlob (to, top, height, left, right, rop)
  688. X+ struct hardware *to;
  689. X+ int top, height, *left, *right, rop;
  690. X+ {
  691. X+     int i;
  692. X+     DevicePoint p1, p2;
  693. X+     for (i=0 ; i<height ; i++) {
  694. X+     p1.dx = left[i];
  695. X+     p2.dx = right[i];
  696. X+     p1.dy = p2.dy = top + i;
  697. X+     BitBltLine(to, p1, p2, rop);
  698. X+     }
  699. X+ }
  700. X+ 
  701. X+  /*
  702. X+   * BitBltBlob () takes a set of pixel coordinates and fills the trapezon
  703. X+   * figure half open.
  704. X+   */
  705. X+ 
  706. X+ #ifdef SLOWANDWRONG
  707. X+ void RasterTile (from, to, toPoint, extent, rop)
  708. X+ struct hardware *from, *to;
  709. X+ DevicePoint toPoint, extent;
  710. X+ int rop;
  711. X+ {
  712. X+     Hardware fromhard, tohard;
  713. X+     DevicePoint p1, p2, p3;
  714. X+     int x, y;
  715. X+     if (to == NULL) return;
  716. X+     if (from == NULL)
  717. X+     Punt("Can only RasterTile from Hardware.");
  718. X+     fromhard = (Hardware) from->hard.addr;
  719. X+     tohard = (Hardware) to->hard.addr;
  720. X+     p1.dx = p1.dy = 0;
  721. X+     for (x=toPoint.dx ; x < toPoint.dx + extent.dx ; x+=from->extent.dx) {
  722. X+     for (y=toPoint.dy ; y < toPoint.dy + extent.dy ; y+=from->extent.dy) {
  723. X+         p2.dx = x;
  724. X+         p2.dy = y;
  725. X+         p3.dx = MIN(toPoint.dx + extent.dx - x, from->extent.dx);
  726. X+         p3.dy = MIN(toPoint.dy + extent.dy - y, from->extent.dy);
  727. X+         BitBlt(from, to, p1, p2, p3, rop);
  728. X+     }
  729. X+     }
  730. X+ }
  731. X+ #endif SLOWANDWRONG
  732. X+ 
  733. X+ 
  734. X+ void RasterTile (from, to, toPoint, extent, rop)
  735. X+ struct hardware *from, *to;
  736. X+ DevicePoint toPoint, extent;
  737. X+ int rop;
  738. X+ {
  739. X+     Hardware fromhard, tohard;
  740. X+     static GC gc = NULL;
  741. X+     XGCValues values;
  742. X+     int valuemask;
  743. X+     if (to == NULL) return;
  744. X+     if (from == NULL || IsWindowHardware(from))
  745. X+     Punt("Can only RasterTile from Bitmap.");
  746. X+     fromhard = (Hardware) from->hard.addr;
  747. X+     tohard = (Hardware) to->hard.addr;
  748. X+     values.tile = fromhard->w;
  749. X+     values.fill_style = FillTiled;
  750. X+     values.function = rop;
  751. X+     valuemask = GCFunction | GCTile | GCFillStyle;
  752. X+     if (gc == NULL)
  753. X+     gc = XCreateGC(dpy, RootWindow(dpy, SCREEN), valuemask, &values);
  754. X+     else
  755. X+     XChangeGC(dpy, gc, valuemask, &values);
  756. X+     XFillRectangle(dpy, tohard->w, gc, toPoint.dx, toPoint.dy,
  757. X+            extent.dx, extent.dy);
  758. X+ }
  759. X+ 
  760. X+ /*
  761. X+  * RasterTile () replicates the whole of ``from'' over ``to'', but clipped by
  762. X+  * the rectangle bounded by ``toPoint'' and ``extent''.
  763. X+  */
  764. X+ 
  765. X+ /******************* BRIGHTNESS TRANSFER FUNCTION ************************/
  766. X+ 
  767. X+ #ifdef CANON
  768. X+ int TransferSize ()
  769. X+ {}
  770. X+ #endif CANON
  771. X+ 
  772. X+ #ifdef CANON
  773. X+ void SetTransfer (vec)
  774. X+ float *vec;
  775. X+ {}
  776. X+ #endif CANON
  777. X+ /*
  778. X+  *     
  779. X+  * TransferSize () and SetTransfer () control the mapping function between
  780. X+  * user brightnesses and device brightnesses. The interface is expected to
  781. X+  * perform this mapping of brightnesses to a sufficient resolution.
  782. X+  * SetTransfer takes a table of floating point numbers between 0 and 1. User
  783. X+  * brightnesses are scaled to the size of this table and mapped through it.
  784. X+  * The argument table given to SetTransfer () will be deleted after use.
  785. X+  * TransferSize () simply enquires the required size of the table.
  786. X+  *     
  787. X+  * It may be appropriate to half-tone on a grayscale or colour device to
  788. X+  * improve rendering if it is not too expensive. TransferSize () returns the
  789. X+  * size of the pattern table.
  790. X+  */
  791. X+ 
  792. X+ /********************** BITMAP CONVERSION ********************************/
  793. X+ 
  794. X+ char *StringFromHardware (h)
  795. X+ struct hardware *h;
  796. X+ {
  797. X+     XImage *image;
  798. X+     Hardware hard;
  799. X+     unsigned char *result, *ptr, c;
  800. X+     int x, y, i;
  801. X+     if (h == NULL) return NULL;
  802. X+     hard = (Hardware) h->hard.addr;
  803. X+     image = XGetImage(dpy, hard->w, 0, 0, h->extent.dx, h->extent.dy,
  804. X+               AllPlanes, ZPixmap);
  805. X+     result = (unsigned char *) malloc(((h->extent.dx + 7) / 8) * h->extent.dy);
  806. X+     ptr = result;
  807. X+     for (y=0 ; y<h->extent.dy ; y++) {
  808. X+     for (x=0 ; x<h->extent.dx ; x+=8) {
  809. X+         c = 0;
  810. X+         for (i=0 ; i<8 ; i++) {
  811. X+         c = c << 1;
  812. X+         if (x+i < h->extent.dx)
  813. X+             c |= XGetPixel(image, x+i, y);
  814. X+         }
  815. X+     }
  816. X+     *ptr++ = c;
  817. X+     }
  818. X+     free((char *) image);
  819. X+     return (char *) result;
  820. X+ }
  821. X+ 
  822. X+ struct hardware *HardwareFromString (s, width, height)
  823. X+ char *s;
  824. X+ int width, height;
  825. X+ {
  826. X+     struct hardware *h = NewBitmapHardware(width, height);
  827. X+     Hardware hard = (Hardware) h->hard.addr;
  828. X+     XImage *image;
  829. X+     if (s == NULL) Punt("HardwareFromString called with NULL string!");
  830. X+     image = XCreateImage(dpy, DefaultVisual(dpy, SCREEN),
  831. X+              DefaultDepth(dpy, SCREEN), ZPixmap, 0, s,
  832. X+              width, height, 8, 0);
  833. X+     image->bitmap_bit_order = MSBFirst;
  834. X+     XPutImage(dpy, hard->w, fillgc[GXcopy], image, 0, 0, 0, 0, width, height);
  835. X+     free((char *) image);
  836. X+     return h;
  837. X+ }
  838. X+ /*
  839. X+  *     
  840. X+  * StringFromHardware () produces a string from its argument which describes
  841. X+  * the bitmap.  The bitmap is returned in row-major order with the leftmost
  842. X+  * bit of each byte in the most significant position. Rows are padded to byte
  843. X+  * boundaries. Only single plane bitmaps are used.
  844. X+  *     
  845. X+  * HardwareFromString () performs the inverse mapping, generating a bitmap
  846. X+  * from a set of bits, given a width and height. Only single plane bitmaps are
  847. X+  * used.
  848. X+  */
  849. X+ 
  850. X+ /************************* HALF-TONE SCREEN *******************************/
  851. X+ 
  852. X+ #ifdef CANON
  853. X+ int ScreenSize (freq, rotation)
  854. X+ float freq, rotation;
  855. X+ {}
  856. X+ #endif CANON
  857. X+ 
  858. X+ #ifdef CANON
  859. X+ void BuildScreen (freq, rotation, x, y)
  860. X+ float freq, rotation, *x, *y;
  861. X+ {}
  862. X+ #endif CANON
  863. X+ 
  864. X+ #ifdef CANON
  865. X+ void SetScreen (freq, rotation, thresh)
  866. X+ float freq, rotation, *thresh;
  867. X+ {}
  868. X+ #endif CANON
  869. X+ /*
  870. X+  * ScreenSize () allows PostScript to determine how large an array of sample
  871. X+  * points to expect.  It should return the length of the side of the sample
  872. X+  * square.
  873. X+  *     
  874. X+  * BuildScreen () returns a set of sampling coordinates to PostScript to hand
  875. X+  * to the users spot-function
  876. X+  *     
  877. X+  * SetScreen () allows PostScript to set the thresholds for each sample point
  878. X+  * so that half-tone bitmaps can be made.
  879. X+  */
  880. X+ 
  881. X+ /************************* CLIPPING ******************************************/
  882. X+ 
  883. X+ #ifdef CANON
  884. X+ void SetClipHardware (h, clip)
  885. X+ struct hardware *h, *clip;
  886. X+ {}
  887. X+ #endif
  888. X+ /*
  889. X+  *     
  890. X+  * SetClipHardware sets hardware which is a clip mask for BitBlt. This mask
  891. X+  * should be ANDed with any output operation. If clip is NULL, masking will
  892. X+  * not be needed.
  893. X+  */
  894. X+ 
  895. X+ /************************ UPDATE CONTROLS **********************************/
  896. X+ 
  897. X+ void HardUpdate ()
  898. X+ {
  899. X+     XFlush(dpy, 0);
  900. X+ }
  901. X+ /*
  902. X+  * HardUpdate is a hook to allow devices which do output buffering to flush
  903. X+  * that buffering when appropriate.  This allows an interactive user to see
  904. X+  * completed graphics between prompts (it is called as a side-effect of the
  905. X+  * PostScript flush operator). Typically is is a no-op.
  906. X+  */
  907. X+ 
  908. X+ void UpdateControl (h, on)
  909. X+ struct hardware *h;
  910. X+ int on;
  911. X+ {}
  912. X+ /*
  913. X+  * This call can be used to enable batching of output operations.
  914. X+  * UpdateControl (h, FALSE) means ``start of batching'' UpdateControl (h,
  915. X+  * TRUE) means ``end of batching''. It is used to improve performance on
  916. X+  * machines where screen updates have a high locking overhead. It may be a
  917. X+  * no-op.  The operation should nest if batching is already in progress: FALSE
  918. X+  * increments a counter, TRUE decrements a counter. Display changes are
  919. X+  * allowed when the counter is non-zero.
  920. X+  */
  921. X+ 
  922. X+ /********************************** CANONICAL IMPLEMENTATION LIBRARY ******************************/
  923. X+ 
  924. X+ /*
  925. X+  * Some parts of the above interface can be supported by a canonical library.
  926. X+  * This library contains:
  927. X+ 
  928. X+ SetClipHardware
  929. X+ HardUpdate
  930. X+ IsWindowHardware
  931. X+ HardwareExtent
  932. X+ 
  933. X+ PaintTrapezoid
  934. X+ BitBltTrapezoid
  935. X+ 
  936. X+ Paint
  937. X+ PaintLine
  938. X+ 
  939. X+ DeviceMatrix
  940. X+ InitTransfer
  941. X+ TransferSize
  942. X+ SetTransfer
  943. X+ ScreenSize
  944. X+ BuildScreen
  945. X+ SetScreen
  946. X+ 
  947. X+  *
  948. X+  * As the driver matures, the user may provide his own versions of the
  949. X+  * canonical routines.  This leaves the following for implementation by 
  950. X+  * the user.
  951. X+  *
  952. X+ 
  953. X+ InitHardware
  954. X+ NewBitmapHardware
  955. X+ NewWindowHardware
  956. X+ DestroyHardware
  957. X+ HardwareFromString
  958. X+ StringFromHardware
  959. X+ UpdateControl
  960. X+ RasterTile
  961. X+ BitBlt
  962. X+ BitBltLine
  963. X+ BitBltBlob
  964. X+ 
  965. X+  * There is a pedagogical implementation in null.c
  966. X+  *    
  967. X+  * There are a number of interface issues concerning the canonical driver.
  968. X+  * Firstly, a canonical struct hardware is defined, which contains a union of
  969. X+  * a char * and an int handle. The remainder are expected to use this to store
  970. X+  * device specific information.
  971. X+  *
  972. X+  * InitTransfer() should be called during InitHardware with the number of 
  973. X+  * pixels per inch on the display as an argument.
  974. X+  */
  975. X+ 
  976. X+ /* I tacked this lot on the end to avoid altering canon.c - CAAG */
  977. X+ 
  978. X+ int pixels_per_inch;
  979. X+ 
  980. X+ int single_rop [] =
  981. X+  {
  982. X+     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  983. X+     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  984. X+     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  985. X+     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE
  986. X+  };
  987. X+ 
  988. X+ /*ARGSUSED*/
  989. X+ Matrix DeviceMatrix (width, height) int width, height;
  990. X+  {
  991. X+      return NewMatrix (pixels_per_inch / 72.0, 0.0, 0.0, -pixels_per_inch / 72.0, 0.0, (float) height);
  992. X+  }
  993. X+ 
  994. X+ int IsWindowHardware (h) struct hardware *h;
  995. X+  {
  996. X+      return h->flags & ISWIN;
  997. X+  }
  998. X+ 
  999. X+ #define IsWindowHardware(h) ((h)->flags & ISWIN)
  1000. X+ 
  1001. X+ DevicePoint HardwareExtent (h) struct hardware *h;
  1002. X+  {
  1003. X+      if (h)
  1004. X+          return h->extent;
  1005. X+      else
  1006. X+          return NewDevicePoint (0, 0);
  1007. X+  }
  1008. X+ 
  1009. X+ void SetClipHardware (h, clip) struct hardware *h, *clip;
  1010. X+  {
  1011. X+      if (h)
  1012. X+         h->clip = clip;
  1013. X+  }
  1014. X+ 
  1015. Xdiff -cr /usr/tmp/ps/source/array.c ./source/array.c
  1016. X*** /usr/tmp/ps/source/array.c    Thu Jul 28 14:01:14 1988
  1017. X--- ./source/array.c    Wed Jul 27 12:02:11 1988
  1018. X***************
  1019. X*** 142,151 ****
  1020. X--- 142,165 ----
  1021. X  int ExecArray (item) Object item;
  1022. X   {
  1023. X       int l = lengthArray (item);
  1024. X+     Object res;
  1025. X+     register Object *rp = &res;
  1026. X       
  1027. X      if (l == 0)
  1028. X           return TRUE;
  1029. X+     /*
  1030. X+      * BZS - try some open-coding here
  1031. X+      *
  1032. X       Push (ExecStack, SameFlags (item, Make (Body (item) + 1, l - 1)));
  1033. X+     */
  1034. X+     rp->type = Array;
  1035. X+     rp->flags = READABLE | WRITEABLE;
  1036. X+     rp->u.Integer = 0;
  1037. X+     rp->u.Array = item.u.Array + 1;
  1038. X+     rp->Length = l - 1;
  1039. X+     rp->flags = item.flags;
  1040. X+     Push(ExecStack,res);
  1041. X+     /* end open-coding */
  1042. X       if (TypeOf (Body (item) [0]) == Name || TypeOf (Body (item) [0]) == Operator)
  1043. X           Push (ExecStack, Body (item) [0]);
  1044. X       else
  1045. Xdiff -cr /usr/tmp/ps/source/config.c ./source/config.c
  1046. X*** /usr/tmp/ps/source/config.c    Thu Jul 28 14:01:20 1988
  1047. X--- ./source/config.c    Thu Jul 28 14:07:25 1988
  1048. X***************
  1049. X*** 92,98 ****
  1050. X      
  1051. X      /* Begin jgm */
  1052. X      strcpy(versionbuf, DriverType);
  1053. X!     strcat(versionbuf, " version 1.4 with jgm mods v2");
  1054. X      Install ("version",    StringFrom (versionbuf));
  1055. X      /* End jgm */
  1056. X   }
  1057. X--- 92,98 ----
  1058. X      
  1059. X      /* Begin jgm */
  1060. X      strcpy(versionbuf, DriverType);
  1061. X!     strcat(versionbuf, " version 1.4 with jgm/bzs mods v3");
  1062. X      Install ("version",    StringFrom (versionbuf));
  1063. X      /* End jgm */
  1064. X   }
  1065. Xdiff -cr /usr/tmp/ps/source/device.c ./source/device.c
  1066. X*** /usr/tmp/ps/source/device.c    Thu Jul 28 14:01:23 1988
  1067. X--- ./source/device.c    Sat Apr 30 17:45:35 1988
  1068. X***************
  1069. X*** 25,31 ****
  1070. X       struct hardware *h;
  1071. X       DevicePoint extent;
  1072. X       
  1073. X!     InstallOp ("framedevice",    FrameDevice,         4, 0, 0, 0, Array, Integer, Integer, Array);
  1074. X      InstallOp ("nulldevice",    NullDevice,        0, 0, 0, 0);
  1075. X      InstallOp ("grabbits",        GrabBits,        4, 0, 0, 0, Float, Float, Float, Float);
  1076. X      
  1077. X--- 25,31 ----
  1078. X       struct hardware *h;
  1079. X       DevicePoint extent;
  1080. X       
  1081. X!     InstallOp ("framedevice",    FrameDevice,         4, 0, 0, 0, Array, Integer, Integer, Poly /* jgm */);
  1082. X      InstallOp ("nulldevice",    NullDevice,        0, 0, 0, 0);
  1083. X      InstallOp ("grabbits",        GrabBits,        4, 0, 0, 0, Float, Float, Float, Float);
  1084. X      
  1085. X***************
  1086. X*** 79,94 ****
  1087. X       return TRUE;
  1088. X   }
  1089. X  
  1090. X- /*ARGSUSED*/
  1091. X  static int FrameDevice (mat, width, height, proc) Object mat, width, height, proc;
  1092. X   {
  1093. X       Matrix m;
  1094. X       
  1095. X       if (lengthArray (mat) != 6 || !ExtractMatrix (&m, mat))
  1096. X           return Error (PTypeCheck);
  1097. X       if (BodyInteger (width) < 0 || BodyInteger (height) < 0)
  1098. X           return Error (PRangeCheck);
  1099. X!      SetDevice (NewWindowDevice (BodyInteger (width) * 8, BodyInteger (height), m));
  1100. X       ErasePage ();
  1101. X       
  1102. X      return TRUE;
  1103. X--- 79,98 ----
  1104. X       return TRUE;
  1105. X   }
  1106. X  
  1107. X  static int FrameDevice (mat, width, height, proc) Object mat, width, height, proc;
  1108. X   {
  1109. X       Matrix m;
  1110. X+     struct device *d;
  1111. X       
  1112. X       if (lengthArray (mat) != 6 || !ExtractMatrix (&m, mat))
  1113. X           return Error (PTypeCheck);
  1114. X       if (BodyInteger (width) < 0 || BodyInteger (height) < 0)
  1115. X           return Error (PRangeCheck);
  1116. X!     /* Begin jgm */
  1117. X!      d = NewWindowDevice (BodyInteger (width) * 8, BodyInteger (height), m);
  1118. X!     d->output_routine = proc;
  1119. X!      SetDevice (d);
  1120. X!     /* End jgm */
  1121. X       ErasePage ();
  1122. X       
  1123. X      return TRUE;
  1124. X***************
  1125. X*** 148,155 ****
  1126. X       res->link_count = 0;
  1127. X       res->default_clip = clip;
  1128. X       res->default_matrix = m;
  1129. X       res->dev = dev;
  1130. X!      
  1131. X       return res;
  1132. X   }
  1133. X  
  1134. X--- 152,160 ----
  1135. X       res->link_count = 0;
  1136. X       res->default_clip = clip;
  1137. X       res->default_matrix = m;
  1138. X+     res->output_routine = Nil;
  1139. X       res->dev = dev;
  1140. X!     
  1141. X       return res;
  1142. X   }
  1143. X  
  1144. Xdiff -cr /usr/tmp/ps/source/device.h ./source/device.h
  1145. X*** /usr/tmp/ps/source/device.h    Thu Jul 28 13:43:09 1988
  1146. X--- ./source/device.h    Sat Apr 30 16:34:02 1988
  1147. X***************
  1148. X*** 9,14 ****
  1149. X--- 9,15 ----
  1150. X       Matrix default_matrix;
  1151. X       Path default_clip;
  1152. X       int link_count;
  1153. X+     Object output_routine; /* jgm */
  1154. X       struct hardware *dev;
  1155. X   };
  1156. X  
  1157. Xdiff -cr /usr/tmp/ps/source/dictionary.c ./source/dictionary.c
  1158. X*** /usr/tmp/ps/source/dictionary.c    Thu Jul 28 13:53:28 1988
  1159. X--- ./source/dictionary.c    Wed Jul 27 12:02:12 1988
  1160. X***************
  1161. X*** 17,24 ****
  1162. X  
  1163. X  Object Absent, Nil, SysDict;
  1164. X  
  1165. X! Object DictLookup (), MakeDict (), DictLoad ();
  1166. X  
  1167. X  static int LengthDict (), CopyDict (), forDict (), ForDict (), PutDict (), GetDict ();
  1168. X  static int PDict (), PBegin (), PEnd (), PDef (), PStore (), PKnown (), PLoad ();
  1169. X  static int PrCheck (), PwCheck (), PReadOnly (), EqDict (); 
  1170. X--- 17,29 ----
  1171. X  
  1172. X  Object Absent, Nil, SysDict;
  1173. X  
  1174. X! /* BZS - DictLoad open-coded */
  1175. X! #ifndef DictLoad
  1176. X! Object DictLoad();
  1177. X! #endif
  1178. X  
  1179. X+ Object DictLookup (), MakeDict ();
  1180. X+ 
  1181. X  static int LengthDict (), CopyDict (), forDict (), ForDict (), PutDict (), GetDict ();
  1182. X  static int PDict (), PBegin (), PEnd (), PDef (), PStore (), PKnown (), PLoad ();
  1183. X  static int PrCheck (), PwCheck (), PReadOnly (), EqDict (); 
  1184. X***************
  1185. X*** 166,171 ****
  1186. X--- 171,182 ----
  1187. X          (a.u.Integer == b.u.Integer || TypeOf (a) == Array && a.Length == 0);
  1188. X   }
  1189. X  
  1190. X+ /* BZS - open code Equal */
  1191. X+ #define Equal(A,B) ((TypeOf(A) == TypeOf(B)) && \
  1192. X+             (A.Length == B.Length) && \
  1193. X+             ((A.u.Integer == B.u.Integer)|| \
  1194. X+              (TypeOf(A) == Array) && (A.Length == 0)))
  1195. X+ 
  1196. X  static DictReplace (hash, key, value, size, h) struct dict_entry *hash; Object key, value; int size, h;
  1197. X   {
  1198. X       int i;
  1199. X***************
  1200. X*** 250,258 ****
  1201. X      DictStore (SysDict, NameFrom (key), value);
  1202. X   }
  1203. X  
  1204. X! static Object DictFind (hash, key, size) struct dict_entry *hash; Object key; int size;
  1205. X   {
  1206. X!      int i, h;
  1207. X       
  1208. X       ++hash_attempts;
  1209. X       
  1210. X--- 261,272 ----
  1211. X      DictStore (SysDict, NameFrom (key), value);
  1212. X   }
  1213. X  
  1214. X! /*
  1215. X!  * BZS - add some register decls, make global for macrification (remove static)
  1216. X!  */
  1217. X! Object DictFind (hash, key, size) struct dict_entry *hash; Object key; int size;
  1218. X   {
  1219. X!      register int i, h;
  1220. X       
  1221. X       ++hash_attempts;
  1222. X       
  1223. X***************
  1224. X*** 266,271 ****
  1225. X--- 280,286 ----
  1226. X       {
  1227. X           if (TypeOf (hash[i].entry_key) == Null)
  1228. X               return Absent;
  1229. X+ 
  1230. X           if (Equal (key, hash[i].entry_key))
  1231. X            {
  1232. X              ++hash_tries;
  1233. X***************
  1234. X*** 279,289 ****
  1235. X--- 294,308 ----
  1236. X       }
  1237. X      return Absent;
  1238. X   }
  1239. X+ #undef Equal
  1240. X  
  1241. X+ /* BZS - macro-ified */
  1242. X+ #ifndef DictLoad
  1243. X  Object DictLoad (dict, key) Object dict, key;
  1244. X   {
  1245. X      return DictFind (Body (dict)->dict_body, key, Body (dict)->dict_size);
  1246. X   }
  1247. X+ #endif
  1248. X  
  1249. X  Object Lookup (dict, key) Type dict; Object key;
  1250. X   {
  1251. Xdiff -cr /usr/tmp/ps/source/fill.c ./source/fill.c
  1252. X*** /usr/tmp/ps/source/fill.c    Thu Jul 28 14:02:56 1988
  1253. X--- ./source/fill.c    Wed Jul 27 12:02:15 1988
  1254. X***************
  1255. X*** 35,41 ****
  1256. X   *    pool
  1257. X   */        
  1258. X  
  1259. X! static struct edge
  1260. X   {
  1261. X      int topX, topY, bottomX, bottomY; short dir;
  1262. X      struct edge *pair;
  1263. X--- 35,41 ----
  1264. X   *    pool
  1265. X   */        
  1266. X  
  1267. X! /* static (removed --jgm) */ struct edge
  1268. X   {
  1269. X      int topX, topY, bottomX, bottomY; short dir;
  1270. X      struct edge *pair;
  1271. X***************
  1272. X*** 70,75 ****
  1273. X--- 70,126 ----
  1274. X  static int FillIt ();
  1275. X  static int EoRule (), NwRule ();
  1276. X  
  1277. X+ /*
  1278. X+  * BZS - Open Code
  1279. X+  */
  1280. X+ #define NotThisBit(EDGE,WHERE,EMITFN) { \
  1281. X+   if((EDGE)->pair != NULL) { \
  1282. X+      (*EMITFN)((EDGE),(EDGE)->pair,(EDGE)->startingY,WHERE); \
  1283. X+      (EDGE)->pair->startingY = WHERE; \
  1284. X+      (EDGE)->pair->where = WHERE; \
  1285. X+      (EDGE)->pair->pair = NULL; \
  1286. X+      (EDGE)->pair = NULL; \
  1287. X+    } \
  1288. X+   (EDGE)->startingY = WHERE; \
  1289. X+   (EDGE)->where = WHERE; \
  1290. X+ }
  1291. X+ 
  1292. X+ #define ThisBit(LEFT,RIGHT,WHERE,EMITFN) { \
  1293. X+    if((LEFT)->pair != (RIGHT) || (RIGHT)->up) { \
  1294. X+      if((LEFT)->pair != NULL) { \
  1295. X+         (*EMITFN)(LEFT,(LEFT)->pair,(LEFT)->startingY,(LEFT)->where); \
  1296. X+         (LEFT)->pair->startingY = (LEFT)->pair->where; \
  1297. X+       (LEFT)->pair->pair->startingY = (LEFT)->pair->pair->where; \
  1298. X+       (LEFT)->pair->pair = NULL; \
  1299. X+      } \
  1300. X+      if ((RIGHT)->pair != NULL) { \
  1301. X+         (*EMITFN) (RIGHT, (RIGHT)->pair, (RIGHT)->startingY, (RIGHT)->where); \
  1302. X+     (RIGHT)->pair->startingY = (RIGHT)->pair->where; \
  1303. X+       (RIGHT)->pair->pair->startingY = (RIGHT)->pair->pair->where; \
  1304. X+       (RIGHT)->pair->pair = NULL; \
  1305. X+      }  \
  1306. X+      (LEFT)->pair = RIGHT; \
  1307. X+      (RIGHT)->pair = LEFT; \
  1308. X+      (LEFT)->startingY = (RIGHT)->startingY = WHERE; \
  1309. X+    } \
  1310. X+    (LEFT)->where = (RIGHT)->where = WHERE; \
  1311. X+    (LEFT)->up = TRUE; \
  1312. X+    (RIGHT)->up = FALSE; \
  1313. X+ }
  1314. X+ 
  1315. X+ #define UpEdge(COUNT_A,COUNT_B,INC_A,INC_B,RULE_A,RULE_B) \
  1316. X+   ((*RULE_B)(COUNT_B+INC_B) && !(*RULE_A)(COUNT_A) && \
  1317. X+    (*RULE_A)(COUNT_A+INC_A)||(*RULE_A)(COUNT_A+INC_A) && \
  1318. X+    !(*RULE_B)(COUNT_B) && (*RULE_B)(COUNT_B+INC_B))
  1319. X+ 
  1320. X+ #define DownEdge(COUNT_A,COUNT_B,INC_A,INC_B,RULE_A,RULE_B) \
  1321. X+   ((*RULE_B)(COUNT_B+INC_B) && (*RULE_A)(COUNT_A) && \
  1322. X+    !(*RULE_A)(COUNT_A+INC_A)||(*RULE_A)(COUNT_A+INC_A) && \
  1323. X+    (*RULE_B)(COUNT_B) && !(*RULE_B)(COUNT_B+INC_B))
  1324. X+ 
  1325. X+ #define Xvalue(AX,AY,BX,BY,CY) \
  1326. X+   ((BX)+((CY)-(BY))*((AX)-(BX))/(float)((AY)-(BY)))
  1327. X+ 
  1328. X  static void EmitTrapezoid (left, right, top, bottom) struct edge *left, *right; int top, bottom;
  1329. X   {
  1330. X       struct edge *temp;
  1331. X***************
  1332. X*** 286,320 ****
  1333. X  
  1334. X  ProcessEdges (rule_a, rule_b, emitfn) int (*rule_a)(), (*rule_b)(); void (*emitfn)();
  1335. X   {
  1336. X!     struct edge *up_edge;
  1337. X!     int i, count_a = 0, count_b = 0;
  1338. X!     /* static void RemoveEdges (); (unused --jgm) */
  1339. X!     
  1340. X!     for (i = 0; i < ninteresting; i++)
  1341. X!      {
  1342. X!          /* static void Emit (); (unused --jgm) */
  1343. X!          int d_a = 0, d_b = 0;
  1344. X!          
  1345. X!          if (interesting[i]->clip)
  1346. X!              d_a = interesting[i]->dir;
  1347. X!          else
  1348. X!              d_b = interesting[i]->dir;
  1349. X  
  1350. X!          if (UpEdge (count_a, count_b, d_a, d_b, rule_a, rule_b))
  1351. X!              up_edge = interesting[i];
  1352. X!          else if (DownEdge (count_a, count_b, d_a, d_b, rule_a, rule_b))
  1353. X!               ThisBit (up_edge, interesting[i], interestingY, emitfn);
  1354. X!          else
  1355. X!               NotThisBit (interesting[i], interestingY, emitfn);
  1356. X!          
  1357. X!          count_a += d_a;
  1358. X!          count_b += d_b;
  1359. X!      }
  1360. X!     if (count_a || count_b)
  1361. X!         fprintf (stderr, "count_a = %dcount_b = %d\n", count_a, count_b);
  1362. X!     PanicIf (count_a || count_b, "something wrong in area fill");
  1363. X   }
  1364. X  
  1365. X  ThisBit (left, right, where, emitfn) struct edge *left, *right; int where; void (*emitfn)();    
  1366. X   {
  1367. X       if (left->pair != right || right->up)
  1368. X--- 337,379 ----
  1369. X  
  1370. X  ProcessEdges (rule_a, rule_b, emitfn) int (*rule_a)(), (*rule_b)(); void (*emitfn)();
  1371. X   {
  1372. X!     register struct edge **intp;
  1373. X!         register struct edge *up_edge;
  1374. X!     register int count_a = 0, count_b = 0;
  1375. X!     register int i;
  1376. X  
  1377. X!     i = ninteresting;
  1378. X!     intp = interesting;
  1379. X!     while(i-- > 0) {
  1380. X!       register int d_a = 0, d_b = 0;
  1381. X! 
  1382. X!       if ((*intp)->clip)
  1383. X!         d_a = (*intp)->dir;
  1384. X!       else
  1385. X!         d_b = (*intp)->dir;
  1386. X! 
  1387. X!       if (UpEdge (count_a, count_b, d_a, d_b, rule_a, rule_b))
  1388. X!         up_edge = *intp;
  1389. X!       else if(DownEdge (count_a, count_b, d_a, d_b, rule_a, rule_b)){
  1390. X!         ThisBit (up_edge,(*intp), interestingY, emitfn);
  1391. X!       }
  1392. X!       else {
  1393. X!         NotThisBit ((*intp),interestingY,emitfn);
  1394. X!       }
  1395. X!       count_a += d_a;
  1396. X!       count_b += d_b;
  1397. X! 
  1398. X!       intp++;
  1399. X!     }
  1400. X! 
  1401. X!     if (count_a || count_b) {
  1402. X!       fprintf (stderr, "count_a = %dcount_b = %d\n", count_a, count_b);
  1403. X!       Panic("something wrong in area fill");
  1404. X!     }
  1405. X   }
  1406. X  
  1407. X+ /* BZS - Open code */
  1408. X+ #ifndef ThisBit
  1409. X  ThisBit (left, right, where, emitfn) struct edge *left, *right; int where; void (*emitfn)();    
  1410. X   {
  1411. X       if (left->pair != right || right->up)
  1412. X***************
  1413. X*** 341,347 ****
  1414. X--- 400,412 ----
  1415. X       left->where = right->where = where;
  1416. X       left->up = TRUE; right->up = FALSE;
  1417. X   }
  1418. X+ #endif
  1419. X  
  1420. X+ /*
  1421. X+  * BZS - Open Code this, it can be called hundreds of thousands of times
  1422. X+  * in even simple pictures. Mooreforms spend 50% of its time in this.
  1423. X+  */
  1424. X+ #ifndef NotThisBit
  1425. X  NotThisBit (edge, where, emitfn) struct edge *edge; int where; void (*emitfn)();    
  1426. X   {
  1427. X       if (edge->pair != NULL)
  1428. X***************
  1429. X*** 355,364 ****
  1430. X        edge->startingY = where;
  1431. X       edge->where = where;
  1432. X   }
  1433. X  
  1434. X  static void RemoveEdges (interestingY, emitfn) int interestingY; void (*emitfn)();
  1435. X   {
  1436. X!      int i, j = 0;
  1437. X       
  1438. X       for (i = 0; i < ninteresting; i++)
  1439. X          if (interesting [i]->bottomY > interestingY)
  1440. X--- 420,430 ----
  1441. X        edge->startingY = where;
  1442. X       edge->where = where;
  1443. X   }
  1444. X+ #endif
  1445. X  
  1446. X  static void RemoveEdges (interestingY, emitfn) int interestingY; void (*emitfn)();
  1447. X   {
  1448. X!      register int i, j = 0;
  1449. X       
  1450. X       for (i = 0; i < ninteresting; i++)
  1451. X          if (interesting [i]->bottomY > interestingY)
  1452. X***************
  1453. X*** 368,385 ****
  1454. X       ninteresting = j;
  1455. X   }
  1456. X  
  1457. X  static int UpEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  1458. X   {
  1459. X       return (*rule_b)(count_b + inc_b) && !(*rule_a) (count_a) && (*rule_a) (count_a + inc_a) ||
  1460. X           (*rule_a)(count_a + inc_a) && !(*rule_b) (count_b) && (*rule_b) (count_b + inc_b);
  1461. X   }
  1462. X! 
  1463. X  static int DownEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  1464. X   {
  1465. X       return (*rule_b)(count_b + inc_b) && (*rule_a) (count_a) && !(*rule_a) (count_a + inc_a) ||
  1466. X           (*rule_a)(count_a + inc_a) && (*rule_b) (count_b) && !(*rule_b) (count_b + inc_b);
  1467. X   }
  1468. X! 
  1469. X  static int EoRule (n) int n;
  1470. X   {
  1471. X      return n & 1;
  1472. X--- 434,453 ----
  1473. X       ninteresting = j;
  1474. X   }
  1475. X  
  1476. X+ #ifndef UpEdge
  1477. X  static int UpEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  1478. X   {
  1479. X       return (*rule_b)(count_b + inc_b) && !(*rule_a) (count_a) && (*rule_a) (count_a + inc_a) ||
  1480. X           (*rule_a)(count_a + inc_a) && !(*rule_b) (count_b) && (*rule_b) (count_b + inc_b);
  1481. X   }
  1482. X! #endif
  1483. X! #ifndef DownEdge
  1484. X  static int DownEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  1485. X   {
  1486. X       return (*rule_b)(count_b + inc_b) && (*rule_a) (count_a) && !(*rule_a) (count_a + inc_a) ||
  1487. X           (*rule_a)(count_a + inc_a) && (*rule_b) (count_b) && !(*rule_b) (count_b + inc_b);
  1488. X   }
  1489. X! #endif
  1490. X  static int EoRule (n) int n;
  1491. X   {
  1492. X      return n & 1;
  1493. X***************
  1494. X*** 405,419 ****
  1495. X      return num / denom;
  1496. X   }
  1497. X  
  1498. X  static int Xvalue (ax, ay, bx, by, cy) int ax, ay, bx, by, cy;
  1499. X   {
  1500. X       return bx + (cy - by) * (ax - bx) / (float) (ay - by);
  1501. X   }
  1502. X  
  1503. X  static int intercmp (aa, bb) char *aa, *bb;
  1504. X   {
  1505. X!      struct edge *a = *(struct edge **) aa, *b = *(struct edge **) bb;
  1506. X!      int sign;
  1507. X      
  1508. X      sign = Xvalue (a->topX, a->topY, a->bottomX, a->bottomY, interestingY + 1) -
  1509. X               Xvalue (b->topX, b->topY, b->bottomX, b->bottomY, interestingY + 1);
  1510. X--- 473,489 ----
  1511. X      return num / denom;
  1512. X   }
  1513. X  
  1514. X+ #ifndef Xvalue
  1515. X  static int Xvalue (ax, ay, bx, by, cy) int ax, ay, bx, by, cy;
  1516. X   {
  1517. X       return bx + (cy - by) * (ax - bx) / (float) (ay - by);
  1518. X   }
  1519. X+ #endif
  1520. X  
  1521. X  static int intercmp (aa, bb) char *aa, *bb;
  1522. X   {
  1523. X!    register struct edge *a = *(struct edge **) aa, *b = *(struct edge **) bb;
  1524. X!    int sign;
  1525. X      
  1526. X      sign = Xvalue (a->topX, a->topY, a->bottomX, a->bottomY, interestingY + 1) -
  1527. X               Xvalue (b->topX, b->topY, b->bottomX, b->bottomY, interestingY + 1);
  1528. X***************
  1529. X*** 424,449 ****
  1530. X  
  1531. X  static void AddInteresting ()
  1532. X   {
  1533. X!     int i;
  1534. X           
  1535. X      nextY = infinity;
  1536. X      for (; here < nedges && edge[here].topY <= interestingY; here++) /* look at each new interesting edge */
  1537. X       {
  1538. X!          int i, n;
  1539. X!          
  1540. X!         for (i = 0; i < ninteresting; i++) /* look at all possible intersections */
  1541. X           {
  1542. X!              int inter = Yintersect (&edge[here], interesting[i]);
  1543. X               
  1544. X!              if (inter >= interestingY && inter <= edge[here].bottomY && inter <= interesting[i]->bottomY)
  1545. X                   AddLowest (inter);
  1546. X           }
  1547. X          n = ninteresting++;
  1548. X!         interesting[n] = &edge[here];
  1549. X!         interesting[n]->pair = NULL;
  1550. X!         interesting[n]->up = FALSE;
  1551. X!         interesting[n]->startingY = interesting[n]->where = edge[here].topY;
  1552. X!         interesting[n]->name = names++;
  1553. X       }
  1554. X      i = NextLowest (interestingY);
  1555. X      if (i)
  1556. X--- 494,526 ----
  1557. X  
  1558. X  static void AddInteresting ()
  1559. X   {
  1560. X!     register int i;
  1561. X!     register struct edge **intp;
  1562. X           
  1563. X      nextY = infinity;
  1564. X      for (; here < nedges && edge[here].topY <= interestingY; here++) /* look at each new interesting edge */
  1565. X       {
  1566. X!          register int i, n;
  1567. X! 
  1568. X!         i = ninteresting;
  1569. X!         intp = interesting;
  1570. X!         while(i-- > 0) /* look at all possible intersections */
  1571. X           {
  1572. X!              int inter = Yintersect (&edge[here], (*intp));
  1573. X               
  1574. X!              if (inter >= interestingY &&
  1575. X!                 inter <= edge[here].bottomY &&
  1576. X!                 inter <= (*intp)->bottomY)
  1577. X                   AddLowest (inter);
  1578. X+             intp++;
  1579. X           }
  1580. X          n = ninteresting++;
  1581. X!         intp = &interesting[n];
  1582. X!         *intp = &edge[here];
  1583. X!         (*intp)->pair = NULL;
  1584. X!         (*intp)->up = FALSE;
  1585. X!         (*intp)->startingY = (*intp)->where = edge[here].topY;
  1586. X!         (*intp)->name = names++;
  1587. X       }
  1588. X      i = NextLowest (interestingY);
  1589. X      if (i)
  1590. X***************
  1591. X*** 450,461 ****
  1592. X          nextY = i;
  1593. X      if (here != nedges && edge[here].topY < nextY)
  1594. X          nextY = edge[here].topY;
  1595. X!     for (i = 0; i < ninteresting; i++)
  1596. X!      {
  1597. X!         if (interesting[i]->topY > interestingY && interesting[i]->topY < nextY)
  1598. X!             nextY = interesting[i]->topY;
  1599. X!         if (interesting[i]->bottomY > interestingY && interesting[i]->bottomY < nextY)
  1600. X!             nextY = interesting[i]->bottomY;
  1601. X       }
  1602. X      qsort ((char *) interesting, (unsigned) ninteresting, sizeof (struct edge *), intercmp);
  1603. X   }
  1604. X--- 527,541 ----
  1605. X          nextY = i;
  1606. X      if (here != nedges && edge[here].topY < nextY)
  1607. X          nextY = edge[here].topY;
  1608. X!     i = ninteresting;
  1609. X!     intp = interesting;
  1610. X!     while(i-- > 0)
  1611. X!       {
  1612. X!         if ((*intp)->topY > interestingY && (*intp)->topY < nextY)
  1613. X!             nextY = (*intp)->topY;
  1614. X!         if ((*intp)->bottomY > interestingY && (*intp)->bottomY < nextY)
  1615. X!             nextY = (*intp)->bottomY;
  1616. X!         intp++;
  1617. X       }
  1618. X      qsort ((char *) interesting, (unsigned) ninteresting, sizeof (struct edge *), intercmp);
  1619. X   }
  1620. X***************
  1621. X*** 462,468 ****
  1622. X  
  1623. X  static void FindInfinity ()
  1624. X   {
  1625. X!      int i;
  1626. X       
  1627. X      infinity = edge[0].topY;
  1628. X      for (i = 0; i < nedges; i++)
  1629. X--- 542,548 ----
  1630. X  
  1631. X  static void FindInfinity ()
  1632. X   {
  1633. X!      register int i;
  1634. X       
  1635. X      infinity = edge[0].topY;
  1636. X      for (i = 0; i < nedges; i++)
  1637. X***************
  1638. X*** 503,509 ****
  1639. X  
  1640. X  static void BuildEdgeList (path, clip) Path path; int clip;
  1641. X   {
  1642. X!      Path p;
  1643. X       HardPoint move, here;
  1644. X       
  1645. X       for (p = path->next; p != path; p = p->next)
  1646. X--- 583,589 ----
  1647. X  
  1648. X  static void BuildEdgeList (path, clip) Path path; int clip;
  1649. X   {
  1650. X!      register Path p;
  1651. X       HardPoint move, here;
  1652. X       
  1653. X       for (p = path->next; p != path; p = p->next)
  1654. X***************
  1655. X*** 533,539 ****
  1656. X  static int NextLowest (y) int y;
  1657. X   {
  1658. X      int res;
  1659. X!     struct lowest *p;
  1660. X      
  1661. X      for (p = lowest; p && p->e <= y; p = lowest)    /* delete any which are now irrelevent */
  1662. X       {
  1663. X--- 613,619 ----
  1664. X  static int NextLowest (y) int y;
  1665. X   {
  1666. X      int res;
  1667. X!     register struct lowest *p;
  1668. X      
  1669. X      for (p = lowest; p && p->e <= y; p = lowest)    /* delete any which are now irrelevent */
  1670. X       {
  1671. X***************
  1672. X*** 551,557 ****
  1673. X  
  1674. X  static void AddLowest (e) int e;
  1675. X   {
  1676. X!      struct lowest *res, *p, *q;
  1677. X       
  1678. X       for (p = lowest; p && p->e < e; q = p, p = p->higher)
  1679. X           ;
  1680. X--- 631,637 ----
  1681. X  
  1682. X  static void AddLowest (e) int e;
  1683. X   {
  1684. X!      register struct lowest *res, *p, *q;
  1685. X       
  1686. X       for (p = lowest; p && p->e < e; q = p, p = p->higher)
  1687. X           ;
  1688. Xdiff -cr /usr/tmp/ps/source/font.c ./source/font.c
  1689. X*** /usr/tmp/ps/source/font.c    Thu Jul 28 14:02:59 1988
  1690. X--- ./source/font.c    Wed Jul 27 12:02:18 1988
  1691. X***************
  1692. X*** 362,372 ****
  1693. X       else
  1694. X           return NewVector (0.0, 0.0, 1.0);
  1695. X   }
  1696. X! 
  1697. X  static int BuildHershey (font, code) Object font, code;
  1698. X   {
  1699. X      Vector met;
  1700. X!     Object *bbox, string, nm;
  1701. X       unsigned char *s;
  1702. X       Path p;
  1703. X       int i, l;
  1704. X--- 362,374 ----
  1705. X       else
  1706. X           return NewVector (0.0, 0.0, 1.0);
  1707. X   }
  1708. X! /*
  1709. X!  * BZS - some small changes to allow macrification of DictLoad()
  1710. X!  */
  1711. X  static int BuildHershey (font, code) Object font, code;
  1712. X   {
  1713. X      Vector met;
  1714. X!     Object *bbox, string, nm, tmp;
  1715. X       unsigned char *s;
  1716. X       Path p;
  1717. X       int i, l;
  1718. X***************
  1719. X*** 373,381 ****
  1720. X--- 375,391 ----
  1721. X       
  1722. X      bbox     = BodyArray (DictLoad (font, FontBBox));
  1723. X      nm     = BodyArray (DictLoad (font, Encoding)) [BodyInteger (code)];
  1724. X+     /*
  1725. X      met     = GetMetrics (DictLoad (DictLoad (font, Metrics), nm));
  1726. X+     */
  1727. X+     tmp = DictLoad(font,Metrics);
  1728. X+     met = GetMetrics(DictLoad(tmp,nm));
  1729. X      met.vx -= 2; /* hershey bodge - they look better closer */
  1730. X+     /*
  1731. X      string     = DictLoad (DictLoad (font, CharStrings), nm);
  1732. X+     */
  1733. X+     tmp = DictLoad(font,CharStrings);
  1734. X+     string = DictLoad(tmp,nm);
  1735. X      
  1736. X      SetCacheDevice (nm, NewPoint (met.vx, met.vy),
  1737. X          BodyReal (bbox[0]), BodyReal (bbox[1]),
  1738. Xdiff -cr /usr/tmp/ps/source/main.h ./source/main.h
  1739. X*** /usr/tmp/ps/source/main.h    Thu Jul 28 13:53:36 1988
  1740. X--- ./source/main.h    Wed Jul 27 12:02:21 1988
  1741. X***************
  1742. X*** 166,170 ****
  1743. X--- 166,176 ----
  1744. X          ((getchbuf != EOF) ? getchbuf : ((BodyFile(file)->available = 0), Close (file), EOF))) \
  1745. X      : GeneralGetch (file))
  1746. X  
  1747. X+ /*
  1748. X+  * BZS - macro-ify some things
  1749. X+  */
  1750. X+ Object DictFind();
  1751. X+ #define DictLoad(DICT,KEY) DictFind((DICT.u.Dictionary)->dict_body,KEY,\
  1752. X+                     (DICT.u.Dictionary)->dict_size)
  1753. X  /* Next line --jgm */
  1754. X  #define PanicIf(flag,s) do { if (flag) Panic(s); } while (0)
  1755. Xdiff -cr /usr/tmp/ps/source/matrix.c ./source/matrix.c
  1756. X*** /usr/tmp/ps/source/matrix.c    Thu Jul 28 14:03:05 1988
  1757. X--- ./source/matrix.c    Wed Jul 27 12:02:22 1988
  1758. X***************
  1759. X*** 393,400 ****
  1760. X  HardPoint ExtToInt (p) Point p;
  1761. X   {
  1762. X      Vector v;
  1763. X!     
  1764. X      v = Transform (NewVector (p.x, p.y, 1.0), gstate->CTM);
  1765. X      return NewHardPoint (v.vx, v.vy);
  1766. X   }
  1767. X  
  1768. X--- 393,413 ----
  1769. X  HardPoint ExtToInt (p) Point p;
  1770. X   {
  1771. X      Vector v;
  1772. X!     register Vector *vp;
  1773. X!     register Matrix *mp;
  1774. X!     register Point *pp;
  1775. X! /*
  1776. X!  * BZS - try open coding this
  1777. X!  *    
  1778. X      v = Transform (NewVector (p.x, p.y, 1.0), gstate->CTM);
  1779. X+  */
  1780. X+     mp = &gstate->CTM;
  1781. X+     vp = &v;
  1782. X+     pp = &p;
  1783. X+ 
  1784. X+     vp->vx = pp->x * mp->A + pp->y * mp->C + mp->tx;
  1785. X+     vp->vy = pp->x * mp->B + pp->y * mp->D + mp->ty;
  1786. X+ 
  1787. X      return NewHardPoint (v.vx, v.vy);
  1788. X   }
  1789. X  
  1790. Xdiff -cr /usr/tmp/ps/source/misc.c ./source/misc.c
  1791. XNo differences encountered
  1792. Xdiff -cr /usr/tmp/ps/source/operator.c ./source/operator.c
  1793. X*** /usr/tmp/ps/source/operator.c    Thu Jul 28 14:03:10 1988
  1794. X--- ./source/operator.c    Wed Jul 27 12:02:23 1988
  1795. X***************
  1796. X*** 203,212 ****
  1797. X   *
  1798. X   */
  1799. X  
  1800. X  int ExecOperator (item) Object item;
  1801. X   {
  1802. X!     struct op_struct *op = Body (item);
  1803. X!     int i, res, (*fn)() = op->fn;
  1804. X      Object arg[7];
  1805. X      
  1806. X      Self = NameOperator (item);
  1807. X--- 203,216 ----
  1808. X   *
  1809. X   */
  1810. X  
  1811. X+ /*
  1812. X+  * BZS - try to speed up a little
  1813. X+  */
  1814. X  int ExecOperator (item) Object item;
  1815. X   {
  1816. X!     register struct op_struct *op = Body (item);
  1817. X!     register int i, res;
  1818. X!     int (*fn)() = op->fn;
  1819. X      Object arg[7];
  1820. X      
  1821. X      Self = NameOperator (item);
  1822. X***************
  1823. X*** 219,225 ****
  1824. X          arg[i] = Pop (OpStack);
  1825. X      for (i = op->arguments - 1; i >= 0; i--)
  1826. X       {
  1827. X!          Type formal = op->argtypes[i], actual = TypeOf (arg[i]);
  1828. X           
  1829. X           if (formal == Float && actual == Integer)
  1830. X                arg[i] = RealInteger (arg[i]);
  1831. X--- 223,229 ----
  1832. X          arg[i] = Pop (OpStack);
  1833. X      for (i = op->arguments - 1; i >= 0; i--)
  1834. X       {
  1835. X!          register Type formal = op->argtypes[i], actual = TypeOf (arg[i]);
  1836. X           
  1837. X           if (formal == Float && actual == Integer)
  1838. X                arg[i] = RealInteger (arg[i]);
  1839. Xdiff -cr /usr/tmp/ps/source/screen.c ./source/screen.c
  1840. X*** /usr/tmp/ps/source/screen.c    Thu Jul 28 13:44:08 1988
  1841. X--- ./source/screen.c    Sat Apr 30 18:44:06 1988
  1842. X***************
  1843. X*** 55,61 ****
  1844. X       struct hardware *shade;
  1845. X   } *screen = NULL;
  1846. X  
  1847. X! static int screen_size, screen_side;
  1848. X  
  1849. X  static int FreqSize (freq) float freq;
  1850. X   {
  1851. X--- 55,61 ----
  1852. X       struct hardware *shade;
  1853. X   } *screen = NULL;
  1854. X  
  1855. X! static int screen_size /* , screen_side (unused --jgm) */;
  1856. X  
  1857. X  static int FreqSize (freq) float freq;
  1858. X   {
  1859. X***************
  1860. X*** 121,127 ****
  1861. X            free ((char *) screen);
  1862. X        }
  1863. X       p = screen = (struct screen *) Malloc ((unsigned) (((screen_size = size * size) + 1) * sizeof (struct screen)));
  1864. X!      screen_side = size;
  1865. X       for (i = 0; i < size; i++)
  1866. X           for (j = 0; j < size; j++)
  1867. X            {
  1868. X--- 121,127 ----
  1869. X            free ((char *) screen);
  1870. X        }
  1871. X       p = screen = (struct screen *) Malloc ((unsigned) (((screen_size = size * size) + 1) * sizeof (struct screen)));
  1872. X!      /* screen_side = size; (unused --jgm) */
  1873. X       for (i = 0; i < size; i++)
  1874. X           for (j = 0; j < size; j++)
  1875. X            {
  1876. Xdiff -cr /usr/tmp/ps/source/state.c ./source/state.c
  1877. X*** /usr/tmp/ps/source/state.c    Thu Jul 28 14:03:20 1988
  1878. X--- ./source/state.c    Sat Apr 30 16:47:57 1988
  1879. X***************
  1880. X*** 123,128 ****
  1881. X--- 123,133 ----
  1882. X  
  1883. X  static int CopyPage ()
  1884. X   {
  1885. X+         /* Begin jgm */
  1886. X+         if (TypeOf(gstate->device->output_routine) != Null) {
  1887. X+         Push(ExecStack, gstate->device->output_routine);
  1888. X+     }
  1889. X+     /* End jgm */
  1890. X       return TRUE;
  1891. X   }
  1892. X  
  1893. Xdiff -cr /usr/tmp/ps/source/stroke.c ./source/stroke.c
  1894. X*** /usr/tmp/ps/source/stroke.c    Thu Jul 28 13:48:04 1988
  1895. X--- ./source/stroke.c    Sat Apr 30 18:26:27 1988
  1896. X***************
  1897. X*** 358,364 ****
  1898. X  int PStrokePath ()
  1899. X   {
  1900. X       Path p, new = NewPath ();
  1901. X!      HardPoint prev, here, move;
  1902. X       enum pelem_type last_type = EHeader;
  1903. X       float angle, last_angle, width = gstate->line_width;
  1904. X       
  1905. X--- 358,364 ----
  1906. X  int PStrokePath ()
  1907. X   {
  1908. X       Path p, new = NewPath ();
  1909. X!      HardPoint /* prev, (unused --jgm) */ here, move;
  1910. X       enum pelem_type last_type = EHeader;
  1911. X       float angle, last_angle, width = gstate->line_width;
  1912. X       
  1913. X***************
  1914. X*** 370,376 ****
  1915. X           switch (p->ptype)
  1916. X            {
  1917. X                 case EMove:
  1918. X!                  prev = here;
  1919. X                   move = here = p->pe.point;
  1920. X                   break;
  1921. X                   
  1922. X--- 370,376 ----
  1923. X           switch (p->ptype)
  1924. X            {
  1925. X                 case EMove:
  1926. X!                  /* prev = here; (unused --jgm) */
  1927. X                   move = here = p->pe.point;
  1928. X                   break;
  1929. X                   
  1930. X***************
  1931. X*** 378,384 ****
  1932. X                     if (last_type == EMove)
  1933. X                         break;
  1934. X                  angle = LineSegment (p, new, IntToExt (here), IntToExt (move), width, last_angle, last_type);
  1935. X!                  prev = here;
  1936. X                   here = move;
  1937. X                   last_type = EHeader;
  1938. X                   break;
  1939. X--- 378,384 ----
  1940. X                     if (last_type == EMove)
  1941. X                         break;
  1942. X                  angle = LineSegment (p, new, IntToExt (here), IntToExt (move), width, last_angle, last_type);
  1943. X!                  /* prev = here; (unused --jgm) */
  1944. X                   here = move;
  1945. X                   last_type = EHeader;
  1946. X                   break;
  1947. X***************
  1948. X*** 385,391 ****
  1949. X                   
  1950. X                 case ELine:
  1951. X                  angle = LineSegment (p, new, IntToExt (here), IntToExt (p->pe.point), width, last_angle, last_type);
  1952. X!                  prev = here;
  1953. X                   here = p->pe.point;
  1954. X                     break;
  1955. X                     
  1956. X--- 385,391 ----
  1957. X                   
  1958. X                 case ELine:
  1959. X                  angle = LineSegment (p, new, IntToExt (here), IntToExt (p->pe.point), width, last_angle, last_type);
  1960. X!                  /* prev = here; (unused --jgm) */
  1961. X                   here = p->pe.point;
  1962. X                     break;
  1963. X                     
  1964. X*** /dev/null    Thu Jul 28 10:26:48 1988
  1965. X--- wwinfo.h    Thu Jul 28 14:36:37 1988
  1966. X***************
  1967. X*** 0 ****
  1968. X--- 1,14 ----
  1969. X+ Now that I've gotten your attention...
  1970. X+ 
  1971. X+ If your system doesn't have the wwinfo.h file, that probably means
  1972. X+ that you don't have the ww window manager, which is rumored to be
  1973. X+ available only to academic sites in the U.K.  In that case, a version
  1974. X+ of the Postscript Interpreter compiled to produce output for ww
  1975. X+ is probably worthless to you.
  1976. X+ 
  1977. X+ Please examine the file source/makefile and select a version that is
  1978. X+ appropriate for you--possible choices include "sunPS", "XPS", and
  1979. X+ "xps".
  1980. X+ 
  1981. X+                 _.John G. Myers
  1982. X+ 
  1983. END_OF_ps.diff.v3
  1984. if test 54477 -ne `wc -c <ps.diff.v3`; then
  1985.     echo shar: \"ps.diff.v3\" unpacked with wrong size!
  1986. fi
  1987. # end of overwriting check
  1988. fi
  1989. echo shar: End of shell archive.
  1990. exit 0
  1991. -- 
  1992. _.John G. Myers        Internet: John.Myers@cs.cmu.edu
  1993.             LoseNet:  ...!seismo!inhp4!wiscvm.wisc.edu!give!up
  1994. "The world is full of bozos.  Some of them even have PhD's in Computer Science"
  1995.